<template>
  <div>
      <f-table ref="table" rowKey="orderDetailsId" size="small" :showSetting="true" setting-key='sb1'  :tableColumns="columns" :multiple="false" :operator="operator" :scroll="scroll" :params="queryParam" :api="api.bod" handler="supplierBondNoPageListHandler">
         <span slot="supplierBondType" slot-scope="text, record, index">
            <a-tag color="#2db7f5" v-if="text==0">不垫付</a-tag>

            <a-tag color="purple" v-if="text==1">底价</a-tag>
            <a-tag color="purple" v-if="text==2">底价+税金</a-tag>
            <a-tag color="purple" v-if="text==3">税金</a-tag>
            <a-tag color="purple" v-if="text==6">底价/2+税金</a-tag>
            <a-tag color="purple" v-if="text==5">全额垫付</a-tag>
            <a-tag color="purple" v-if="text==8">销售金额*费率</a-tag>
        </span>
        <span slot="customBondType" slot-scope="text, record, index">
           <a-tag color="#2db7f5" v-if="text==0">全款</a-tag>
            <a-tag color="purple" v-if="text==1">底价</a-tag>
            <a-tag color="purple" v-if="text==2">底价+税金</a-tag>
            <a-tag color="purple" v-if="text==6">底价/2+税金</a-tag>
            <a-tag color="purple" v-if="text==3">税金</a-tag>
            <a-tag color="purple" v-if="text==5">全额资信</a-tag>
            <a-tag color="purple" v-if="text==7">预付款</a-tag>
        </span>
        <span slot="action" slot-scope="text, record">
          <template>
            <a @click="$refs.orderInfoDrawer.showDrawer(record)" >查看</a>
            <a-divider type="vertical"/>
            <a href="javascript:;"  @click="$refs['osbd'].showDrawer(record)">申请垫付</a>
          </template>
        </span>
      </f-table>
     <supplier-bond-drawer ref="osbd" @success="onLoad"></supplier-bond-drawer>
    <order-info-drawer ref="orderInfoDrawer"></order-info-drawer>

  </div>
</template>
<script>
  import api from './../js/api'
  import SupplierBondDrawer from './supplierbond_drawer'
  import OrderInfoDrawer from '../../../business/order/order_info_drawer'

  export default {
    name: 'SupplierBondNo',
    components: {
      OrderInfoDrawer,
      SupplierBondDrawer
    },
    data() {
      let me = this
      //操作按钮
      let operator = []
      return {
        api: Object.assign(api, this.api),
        //列表初始化查询参数
        queryParam: {},
        scroll: { x: true },
        // 表头
        columns: [
          {
            title: '#',
            width: '50px',
            fixed: 'left',
            align: 'left',
            customRender: (text, record, index) => index + 1
          },
          {
            title: '操作',
            align: 'center',
            width: '150px',
            fixed: 'left',
            scopedSlots: { customRender: 'action' }
          },
          {
            title: '单号',
            align: 'left',
            fixed: 'left',
            width: '125px',
            dataIndex: 'orderNo'
          },
          {
            title: '发货日期',
            align: 'left',
            width: '100px',
            dataIndex: 'sendDate'
          },
          {
            title: '部门',
            align: 'left',
            width: '80px',
            dataIndex: 'deptName'
          },
          {
            title: '业务员',
            align: 'left',
            width: '100px',
            dataIndex: 'saleManName'
          },
          {
            title: '数量',
            align: 'left',
            width: '60px',
            dataIndex: 'saleNum'
          },
          {
            title: '药品名称',
            align: 'left',
            width: '120px',
            ellipsis: true,
            dataIndex: 'drugsName'
          },
          {
            title: '规格',
            align: 'left',
            width: '80px',
            dataIndex: 'drugsSpec'
          },
          {
            title: '供货方',
            align: 'left',
            width: '180px',
            ellipsis: true,
            dataIndex: 'supplierName'
          },
          {
            title: '供方资信',
            align: 'left',
            width: '100px',
            ellipsis: true,
            dataIndex: 'supplierBondType',
            scopedSlots: { customRender: 'supplierBondType' }
          },
          {
            title: '购货方',
            align: 'left',
            ellipsis: true,
            width: '180px',
            dataIndex: 'customName'
          },
          {
            title: '购方资信',
            align: 'left',
            width: '100px',
            dataIndex: 'customBondType',
            scopedSlots: { customRender: 'customBondType' }
          },
          {
            title: '收款金额',
            align: 'left',
            width: '100px',
            dataIndex: 'takeAmount'
          },
          {
            title: '制单人',
            align: 'left',
            width: '100px',
            dataIndex: 'nickName'
          },
          {
            title: '垫付款',
            align: 'left',
            width: '100px',
            fixed: 'right',
            dataIndex: 'supplierBond'
          }
        ],
        operator: operator
      }
    },
    created() {
    },
    methods: {
      onLoad() {
        this.$refs.table.refresh()
        this.$emit('changeTab')
      }
    }
  }
</script>
